package com.example.elysiumease.exception;

public class BusinessException extends RuntimeException {
    private static final long serialVersionUID = 1L; // 序列化版本号
    private final int code;

    // 完整参数的构造函数
    public BusinessException(int code, String message) {
        super(message);
        this.code = code;
    }

    // 默认错误码的构造函数
    public BusinessException(String message) {
        this(400, message);
    }

    // 获取错误码的方法
    public int getCode() {
        return code;
    }

    // 可选：重写toString方便调试
    @Override
    public String toString() {
        return "BusinessException{" +
                "code=" + code +
                ", message=" + getMessage() +
                '}';
    }
}
